
package com.joysuch.wwyt.workflow.enums;

public enum WorkFlowAssignKey {

    PERSON("person", "人员"),
    DEPARTMENT("department", "部门"),
    JOB("job", "岗位"),
    ROLE("role", "角色"),
    FORM_OBJECT("formObject", "表单组件");

    String code;
    String name;

    private WorkFlowAssignKey(String code, String name) {
        this.code = code;
        this.name = name;
    }

    public String getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public boolean is(String code) {
        return this.code.equals(code);
    }

    public static WorkFlowAssignKey findByCode(String code) {
        if (code == null) {
            return null;
        }
        for (WorkFlowAssignKey m : WorkFlowAssignKey.values()) {
            if (m.code.equals(code)) {
                return m;
            }
        }
        return null;
    }

    public static String findNameByCode(String code) {
        WorkFlowAssignKey m = findByCode(code);
        return m == null ? null : m.getName();
    }
}
